package cn.itcast.controller;

import cn.itcast.constant.MessageConstant;
import cn.itcast.entity.Result;
import cn.itcast.pojo.Address;
import cn.itcast.service.MobileAddressService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@CrossOrigin
@RestController
@RequestMapping("/address")
@Slf4j
public class AddressController {
    @Reference
    private MobileAddressService mobileAddressService;

    /**
     * 查询所有分院地址列表
     * @return
     */
    @GetMapping("/findAll")
    public Result findAllAddress(){

        try {
            List<Address> addressList = mobileAddressService.findAllAddress();

            return new Result(true, MessageConstant.QUERY_ADDRESS_SUCCESS,addressList);
        } catch (Exception e) {
            log.error("查询分院地址列表失败",e);
        }
        return new Result(false,MessageConstant.QUERY_ADDRESS_FAIL,null);
    }
}
